package com.lepu.app.fun.tool.tefypc.bean;

import java.util.ArrayList;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.app.utils.DBHelper;

public class BeanToolTaiEr {
	private static final String TABLE_NAME = "ToolTaiErNew";

    public String weeks;
    public String BPDMin;
    public String BPDAvarage;
    public String BPDMax;
    public String ACMin;
    public String ACAvarage;
    public String ACMax;
    public String FLMin;
    public String FLAvarage;
    public String FLMax;

    //获取所有数据
    public static ArrayList<BeanToolTaiEr> getData(String week) {
    	ArrayList<BeanToolTaiEr> provinces = new ArrayList<BeanToolTaiEr>();
		DBHelper dbHelp = DBHelper.getInstance(DBHelper.DATABASE_NAME_TOOL);
		if (dbHelp == null)
			return provinces;

		SQLiteDatabase dbSqlite = null;
		try {
			dbSqlite = dbHelp.getWritableDatabase();

			Cursor queryResult = dbSqlite.query(TABLE_NAME, 
					new String[] {"weeks","BPDMin", "BPDAvarage", "BPDMax", "ACMin","ACAvarage", "ACMax", "FLMin", "FLAvarage", "FLMax"},
					"weeks=?",new String[] {week}, null, null,null);
			cursorParse(provinces, queryResult);
			dbSqlite.close();
		} catch (Exception e) {
		}

		return provinces;
    }
    
	private static void cursorParse(ArrayList<BeanToolTaiEr> msgArray,Cursor cursor) {
		while (cursor.moveToNext()) {

			BeanToolTaiEr beanTarget = new BeanToolTaiEr();
			beanTarget.weeks = (cursor.getString(cursor.getColumnIndex("weeks")));
			beanTarget.BPDMin = (cursor.getString(cursor.getColumnIndex("BPDMin")));
			beanTarget.BPDAvarage = (cursor.getString(cursor.getColumnIndex("BPDAvarage")));
			beanTarget.BPDMax = (cursor.getString(cursor.getColumnIndex("BPDMax")));
			beanTarget.ACMin = (cursor.getString(cursor.getColumnIndex("ACMin")));
			beanTarget.ACAvarage = (cursor.getString(cursor.getColumnIndex("ACAvarage")));
			beanTarget.ACMax = (cursor.getString(cursor.getColumnIndex("ACMax")));
			beanTarget.FLMin = (cursor.getString(cursor.getColumnIndex("FLMin")));
			beanTarget.FLAvarage = (cursor.getString(cursor.getColumnIndex("FLAvarage")));
			beanTarget.FLMax = (cursor.getString(cursor.getColumnIndex("FLMax")));

			msgArray.add(beanTarget);
		}
	}
	
}
